package top.oneit.jdownload.test;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Paint;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import org.kordamp.ikonli.javafx.FontIcon;

import java.net.URL;

/**
 * @author lingkang
 */
public class Ikonli01 extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        // 加载 xml
//        URL resource = getClass().getResource("/fxml/test/ikonli-icon.fxml");
//        AnchorPane load = FXMLLoader.load(resource);

        AnchorPane anchorPane=new AnchorPane();
        anchorPane.setPrefWidth(400);
        anchorPane.setPrefHeight(300);

        FontIcon fontIcon=new FontIcon("fa-address-card-o");
        fontIcon.setFill(Paint.valueOf("red"));

        // 图标需要放在label中，或者其他标签，例如按钮等
        Label label=new Label();
        label.setGraphic(fontIcon);
        label.setFont(Font.font(18));
        label.setLayoutX(10);
        label.setLayoutY(10);

        FontIcon icon=new FontIcon("fa-apple");

        Button button=new Button("图标按钮");
        button.setGraphic(icon);
        button.setLayoutX(10);
        button.setLayoutY(40);
        button.setFont(Font.font(30));
        anchorPane.getChildren().addAll(label,button);
        primaryStage.setScene(new Scene(anchorPane));
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}